package org.yanh.user.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.yanh.user.service.IUserService;
@Tag(name="用户相关接口",description = "用户相关接口")
@RestController
@ApiSupport(author = "yanh")
@RequestMapping("/userinfo")
@RequiredArgsConstructor
public class UserInfoController {
    private final IUserService userService;
    @Operation(summary = "当前用户信息",description = "当前用户信息")
    @GetMapping
    public String getUserInfo(){
        return "";
    }
    @Operation(summary = "获取用户信息",description = "获取用户信息")
    @GetMapping("/{id}")
    public String getTest(@PathVariable("id")  String id){
        return id;
    }
    @Operation(summary = "扣减余额",description = "扣减余额")
    @Parameters(value = {
            @Parameter(name = "pw", description = "pw", example = "1"),
            @Parameter(name = "amount", description = "amount", example = "5")
    })
    @PutMapping("/moneyDeduct")
    public void deductMoney(@RequestParam("pw") String pw, @RequestParam("amount") Integer amount){
        userService.deductMoney(pw, amount);
    }
}
